﻿using System;
using System.Collections;
using System.Collections.Generic;
using EraNet.Core;
using EraNet.Core.Model.Account;
using EraNet.Core.Model.SysManage;
using System.Data;

namespace EraNet.Services.SysManage
{
    public partial interface ISysCardsService
    {
        /// <summary>
        /// 插入卡信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        int InsertCard(SysCards model);
        /// <summary>
        /// 批量插入卡信息
        /// </summary>
        /// <param name="cards"></param>
        /// <returns></returns>
        int InsertCards(IList<SysCards> cards, bool IsAstrict);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="startNo"></param>
        /// <param name="Number"></param>
        /// <param name="clientId"></param>
        /// <returns></returns>
        int InsertCards(string startNo, int Number, int clientId, bool IsAstrict);
        /// <summary>
        /// 根据卡ID获取卡信息
        /// </summary>
        /// <param name="cardId"></param>
        /// <returns></returns>
        SysCards GetCardById(int cardId);
        /// <summary>
        /// 根据卡号获取卡信息
        /// </summary>
        /// <param name="cardNo"></param>
        /// <returns></returns>
        SysCards GetCardByNo(string cardNo);
        /// <summary>
        /// 激活卡
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="cardPwd"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        int ActiveCard(string cardNo, string cardPwd, int userId);
        /// <summary>
        /// 批量获取卡信息
        /// </summary>
        /// <param name="startNo">卡起始的编号</param>
        /// <param name="mark">卡的标识（0抛弃，其他的对应卡片发放的对象ID）</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="isShowHide">是否要包含使用过的卡</param>
        /// <returns></returns>
        IPagedList<SysCards> GetAllCards(string cardNo, int pageSize, int pageIndex, bool isShowHide);

        /// <summary>
        /// 根据卡号/密码获取信息
        /// </summary>
        /// <param name="cardNo"></param>
        /// <returns></returns>
        SysCards GetCardByNo(string cardNo, string cardPwd);
        
        /// <summary>
        /// 获取单张未使用的学习卡
        /// </summary>
        /// <param name="cardNo"></param>
        /// <returns></returns>
        SysCards GetSingleCardBySchoolId(int schoolId);
        

        /// <summary>
        /// 根据驾校ID获取所有学习卡信息 包括用户信息
        /// </summary>
        /// <param name="cardNo"></param>
        /// <returns></returns>
        DataTable GetCardsBySchoolId(int schoolId, string cardNo, int pageIndex, int pageSize, out int count);
        

        /// <summary>
        /// 批量获取使用过的卡信息
        /// </summary>
        /// <param name="mark">卡标识</param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        IPagedList<SysCards> GetAllUsedCards(string mark, int pageSize, int pageIndex);

        #region AllotLogs
        Member GetMemberByCards(string cardNo, string cardPwd);

         /// <summary>
        /// 根据ID获取数据信息
        /// </summary>
        /// <param name="cardId"></param>
        /// <returns></returns>
        CardAllotLogs GetCardAllotLogsById(int cardId);
        

        /// <summary>
        /// 根据学员ID获取卡片分配记录
        /// </summary>
        /// <param name="cardNo"></param>
        /// <returns></returns>
        List<CardAllotLogs> GetCardAllotLogs(int[] arrMemberId);
        
         /// <summary>
        /// 更新学习卡
        /// </summary>
        /// <param name="SysCards">卡片实体</param>
        /// <returns>0-〉更新失败 1-〉更新成功</returns>
        int UpdateSysCards(SysCards card);
        

        /// <summary>
        /// 分配学习卡
        /// </summary>
        /// <param name="cal"></param>
        /// <returns></returns>
        bool InsertCardAllotLog(CardAllotLogs cal, int cardId);

        /// <summary>
        /// 更新学习卡记录
        /// </summary>
        /// <param name="cal"></param>
        /// <returns></returns>
        bool UpdCardAllotLog(CardAllotLogs cal);
        

         /// <summary>
        /// 判断卡片是已经分配学员
        /// </summary>
        /// <param name="cal"></param>
        /// <returns></returns>
        bool isExistsByCardNo(string cardNo);
        
        
        #endregion


         /// <summary>
        /// 根据用户获取 管理的卡片信息
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="cardPwd"></param>
        /// <returns></returns>
        SysCards GetCardsByMemberId(int MemberId);

        /// <summary>
        /// 修改实体 不需要再次查询
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        int MyUpdate(SysCards card);
        

        /// <summary>
        /// 获取登录学员实体
        /// </summary>
        /// <returns></returns>
        SysCards GetLoginSysCards();
        
        
    }
}
